<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
   select{
     width: 200px;
     height: 200px;
     background-color: teal;
     font-size: 20px;
   }
   .btn_box{
     width: 30px;
     display: inline-block;
     position: relative;
     top: -30px;
   }
   button{
    width: 30px;
    height: 30px;
    margin-bottom: 10px;
   }
  </style>
</head>
<body>
  <h1>城市选择</h1>
  <select name="src-city" id="leftSelect" multiple>
    <option value="1">北京</option>
    <option value="2">上海</option>
    <option value="3">深圳</option>
    <option value="4">广州</option>
    <option value="5">西红柿</option>
  </select>
  <div class="btn_box">
    <button id="allRight">&gt;&gt;</button>
    <button id="allLeft">&lt;&lt;</button>
    <button id="right">&gt;</button>
    <button id="left">&lt;</button>
  </div>
  <select name="tar-city" id="rightSelect" multiple></select>

  <script src="../jquery-1.12.4.min.js"></script>
  <script>
    //1 点击全部向右的按钮 全部向右移动
    $('#allRight').click(function(){
      //方法一
      $('#leftSelect>option').appendTo('#rightSelect');
      //方法二
      $('#leftSelect').children().appendTo('#rightSelect');
    });
    //2 点击全部向左的按钮 全部向左移动(要求还用append()做练习)
    $('#allLeft').click(function(){
      //方法一
      $('#leftSelect').append($('#rightSelect>option'));
      //方法二
      $('#leftSelect').append($('#rightSelect').children());
    });
    //3 点击右移动功能按钮 选中内容被移动到右边
    $('#right').click(function(){
      //使用 :selected 选择器 直接获取到被选中的选项
      $('#leftSelect>option:selected').appendTo('#rightSelect');
    });
     //4 点击左移动功能按钮 选中内容被移动到左边(要求还用append()做练习)
     $('#left').click(function(){
       $('#leftSelect').append($('#rightSelect>option:selected'));
     });
  </script>
</body>
</html>